<template>
  <div>
    <van-nav-bar title="测试" class="van_bar" />
    <div class="content" v-if="id">
      <van-button plain type="primary" @click="gotoContent('exam')">考试模式</van-button>
      <van-button plain type="info" @click="gotoContent('study')">学习模式</van-button>
    </div>
    <div v-else class="content">
      <van-button plain type="info" @click="goLogin">登录</van-button>
    </div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";
export default {
  name: "test",
  layout: "layoutMain",
  methods: {
    ...mapMutations("exam", ["setType"]),
    gotoContent(type) {
      this.setType(type);
      this.$router.push("/testcontent");
    },
    goLogin() {
      this.$router.push("/login");
    }
  },
  computed: {
    id() {
      return this.$store.state.user.id;
    }
  }
};
</script>

<style lang="scss" scoped>
.van_bar {
  position: fixed;
  top: 0;
  width: 100%;
}
.content {
  position: absolute;
  top: 46px;
  bottom: 50px;
  overflow-y: auto;
  width: 100%;
}
.van-button {
  width: 100px;
  height: 40px;
  margin-left: 37%;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>